package pers.qianyu.month_202012.date_20201228;

import java.util.*;

/**
 * 8. 二维费用的背包问题
 * https://www.acwing.com/problem/content/8/
 *
 * @author mizzle rain
 * @date 2020-12-28 20:00
 */
public class BagTwoDimensional {
    private int N;
    // 容量
    private int V;
    // 承受的最大重量
    private int M;

    private int[] volumes;
    private int[] weights;
    private int[] values;

    public void input() {
        Scanner sc = new Scanner(System.in);
        String[] strs = sc.nextLine().split(" ");
        N = Integer.parseInt(strs[0]);
        V = Integer.parseInt(strs[1]);
        M = Integer.parseInt(strs[2]);
        volumes = new int[N];
        weights = new int[N];
        values = new int[N];
        int i = 0;
        while (sc.hasNext()) {
            volumes[i] = sc.nextInt();
            weights[i] = sc.nextInt();
            values[i] = sc.nextInt();
            i++;
        }
        sc.close();
    }

    public int solve() {
        int[][] dp = new int[V + 1][M + 1];
        for (int i = 0; i < N; i++) {
            for (int j = V; j >= volumes[i]; j--) {
                for (int k = M; k >= weights[i]; k--) {
                    dp[j][k] = Math.max(dp[j][k], dp[j - volumes[i]][k - weights[i]] + values[i]);
                }
            }
        }
        return dp[V][M];
    }

    public static void main(String[] args) {
        BagTwoDimensional solution = new BagTwoDimensional();
        solution.input();
        int result = solution.solve();
        System.out.println(result);
    }

}
